package com.luokangtao.xxlJob.handler;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 任务Handler
 *
 * BEAN模式 开发步骤：
 * 1、继承"IJobHandler"：“com.xxl.job.core.handler.IJobHandler”；
 * 2、注册到Spring容器：添加“@Component”注解，被Spring容器扫描为Bean实例；
 * 3、注册到执行器工厂：添加“@JobHandler(value="自定义jobhandler名称")”注解，注解value值对应的是调度中心新建任务的JobHandler属性的值。
 * 4、执行日志：需要通过 "XxlJobLogger.log" 打印执行日志；
 *
 * @author luokangtao
 * @create 2019-07-31 11:17
 */
@Slf4j
@Component
@JobHandler(value = "xxlJobHandler")//注册到执行器工厂,注解value值对应的是调度中心新建任务的JobHandler属性的值。
public class XxlJobHandler extends IJobHandler {
    @Override
    public ReturnT<String> execute(String param) throws Exception {
        XxlJobLogger.log("XXL-Job传递的参数是："+param); //xxljob专属日志
        log.info("XXL-Job传递的参数是："+param);
        /**
         *     public static final ReturnT<String> SUCCESS = new ReturnT(200, (String)null);
         *     public static final ReturnT<String> FAIL = new ReturnT(500, (String)null);
         *     public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT(502, (String)null);
         */
        return SUCCESS;
    }
}
